function member_freeboard()
{
	//#################################################################
	//
	// 1. 목록 조회
	//
	//#################################################################
	var _listPage 	= new PageInfo( document.getElementById( 'selectFreeBoard' ) );
	$( "#btn_freeBoardRefresh" ).click(function(e) {
		selectAllFreeBoard( _listPage.current, _listPage.numPerPage, boardRefreshSuccess, boardRefreshFail );
	});
	
	// 조회 성공
	function boardRefreshSuccess( data )
	{
		// 성공 핸들러
		setResult( '[게시물 조회] 성공' );
		
		var $listContainer = $( "#selectFreeBoard>.list" );
		// 비우기
		$listContainer.find( '.btnView' ).unbind( "click" );
		$listContainer.find( '.btnEdit' ).unbind( "click" );
		$listContainer.find( '.btnDelete' ).unbind( "click" );
		$listContainer.empty();
		
		// 타이틀 추가
		var _tr;
		_tr = "<thead>";
		_tr += "<tr>";
		_tr += 		"<td>NO</td>";
		_tr +=  	"<td>TITLE</td>";
		_tr +=  	"<td>DESC</td>";
		_tr +=  	"<td>작성자</td>";
		_tr +=  	"<td>작성일</td>";
		_tr +=  	"<td>상세보기</td>";
		_tr +=  	"<td>EDIT</td>";
		_tr +=  	"<td>DELETE</td>";
		_tr += "</tr>";
		_tr += "</thead>";
		_tr += "<tbody>";
		// 리스트 추가
		var _no = (_listPage.current-1)*_listPage.numPerPage+1;
		for( var index in data.item )
		{
			var _item = data.item[ index ];
			_tr += "<tr>";
			_tr += 		"<td>"+(_no++)+"</td>";
			_tr += 		"<td>"+_item[ 'title' ]+"</td>";
			_tr += 		"<td>"+_item[ 'desc' ]+"</td>";
			_tr += 		"<td>"+_item[ 'owner_nickname' ]+"</td>";
			_tr += 		"<td>"+_item[ 'regist_date' ]+"</td>";
			_tr += 		"<td>"+"<input type='button' class='btnView' value='VIEW' data='"+_item[ 'seq' ]+"'/>"+"</td>";
				
			// 수정 가능 여부
			if( login_member_id() == _item[ 'owner_id' ] )
			{
				_tr += 		"<td>"+"<input type='button' class='btnEdit' value='EDIT' data='"+_item[ 'seq' ]+"'/>"+"</td>";
				_tr += 		"<td>"+"<input type='button' class='btnDelete' value='DELETE' data='"+_item[ 'seq' ]+"'/>"+"</td>";
			}else{
				_tr += 		"<td></td>";
				_tr += 		"<td></td>";
			}
			
			_tr += "</tr>";
		}
		_tr += "</tbody>";
		$listContainer.append( _tr );
		
		// 상세보기 버튼 이벤트 등록
		$listContainer.find( '.btnView' ).bind( "click", null, function(e) {
			var $board_seq = $(this).attr( 'data' );
			showDetailFreeBoardPopup( $board_seq );
		});
		// 수정 버튼 이벤트 등록
		$listContainer.find( '.btnEdit' ).bind( "click", null, function(e) {
			var $board_seq = $(this).attr( 'data' );
			showUpdateFreeBoardPopup( $board_seq );
		});
		// 삭제 버튼 이벤트 등록
		$listContainer.find( '.btnDelete' ).bind( "click", null, function(e) {
			var $board_seq = $(this).attr( 'data' );
			disactiveFreeBoard( $board_seq );	// 비활성 처리
		});
		
		// 페이징
		_listPage.setTotalCount( data.count );
		_listPage.updateLabelField();
	}
	
	// 조회 실패
	function boardRefreshFail( data )
	{
		setResultFailForJSON( '[게시물 조회] 실패', data );
	};
	
	// 상세 조회
	function showDetailFreeBoardPopup( $board_seq )
	{
		$.post(
			getGatePath()
			,
			{
				__key__: 'selectFreeBoardDetail',
				__returnType__: 'json',
				seq: $board_seq
			}
			,
			function( data )
			{
				if( data.result == "SUCCESS" )
				{
					var $popup = $( '#selectFreeBoardDetail' );
					$popup.show();
					
					$popup.find( '.boardSeq' ).val( $board_seq );
					
					$popup.find( '[name="title"]' ).val( data[ 'title' ] );
					$popup.find( '[name="ownerNickname"]' ).val( data[ 'owner_nickname' ] );
					$popup.find( '[name="ownerId"]' ).val( data[ 'owner_id' ] );
					$popup.find( '[name="registDate"]' ).val( data[ 'regist_date' ] );
					$popup.find( '[name="desc"]' ).val( data[ 'desc' ] );
					
					// 썸네일 정보
					var _thumbnails = [];
					if( data[ 'thumbnails' ] && data[ 'thumbnails' ][ 'thumb' ] )
					{
						for( var idx in data[ 'thumbnails' ][ 'thumb' ] )
						{
							var _link = data[ 'thumbnails' ][ 'thumb' ][ idx ].link;
							_thumbnails.push( 'no.'+(parseInt(idx)+1)+' '+_link+'('+createViewImageLink(_link)+')' );
						}
					}
					$popup.find( '#freeBoardThumbs .thumbs' ).empty().append( _thumbnails.join( '<br/>' ) );	
					
					// 댓글 가져오기
					$( '#btn_freeBoardCommentRefresh' ).click();
				}
			}
			,
			'json' );
	}
	
	//#################################################################
	//
	// 2. 게시물 등록
	//
	//#################################################################
	$( '#btn_writeFreeBoard' ).click(function(e) {
        var $popup = $( '#insertFreeBoard' );
		$popup.show();
		
		// 기본 정보 입력
		$popup.find( "[name='ownerNickname']" ).val( login_member_nickname() );
    });
	
	$( '#insertFreeBoardForm' ).submit( function( e )
	{
		e.preventDefault();
		
		var _formData = new FormData( document.getElementById( 'insertFreeBoardForm' ) );
		_formData.append( '__key__', 'insertFreeBoard' );
		_formData.append( '__returnType__', 'json' );
		_formData.append( 'login_member_id', login_member_id() );
		_formData.append( 'login_member_session', login_member_session() );
		
		$.ajax(
		{
			url: getGatePath(),
			data: _formData,
			dataType:'json',
			processData: false,
			contentType: false,
			type: "POST",
			success: function( data )
			{
				if( data.result == 'SUCCESS' )
				{
					setResult( '[게시물 추가] 성공' );
					
					var $popup = $( '#insertFreeBoard' );
					$popup.hide();
					// 리스트 갱신
					selectAllFreeBoard( _listPage.current, _listPage.numPerPage, boardRefreshSuccess, boardRefreshFail );
				}else{
					setResultFailForJSON( '[게시물 추가] 실패', data );
				}
			}
		});
	});
	
	//#################################################################
	//
	// 3. 댓글 달기
	//
	//#################################################################
	// 목록 조회
	var _commentPage 	= new PageInfo( document.getElementById( 'freeBoardComments' ) );
	_commentPage.numPerPage = 5;
	$( '#btn_freeBoardCommentRefresh' ).click(function(e) {
        selectAllFreeBoardComments( _commentPage.current, _commentPage.numPerPage, freeBoardCommentsRefreshSuccess, freeBoardCommentsRefreshFail );
    });
	
	function selectAllFreeBoardComments( page, numPerPage, completeHandler, failHandler )
	{
		$.post( getGatePath(),
		{
			__key__: 'selectFreeBoardComments',
			__returnType__: 'json',			
			login_member_id: login_member_id(),
			login_member_session: login_member_session(),
			boardSeq: $( '#insertFreeBoardCommentForm' ).find( '.boardSeq' ).val(),
			page: page,
			numPerPage: numPerPage
		},
		function( data )
		{
			if( data.result == "SUCCESS" )
			{
				// 완료 콜백
				if( completeHandler )
				{
					completeHandler.call( null, data );
				}
			}else{
				// 실패 콜백
				if( failHandler )
				{
					failHandler.call( null, data );
				}
			}
		},
		'json');
	}
	// 조회 성공
	function freeBoardCommentsRefreshSuccess( data )
	{
		// 성공 핸들러
		setResult( '[댓글 조회] 성공' );
		
		var $listContainer = $( "#freeBoardComments>.list" );
		// 비우기
		$listContainer.find( '.btnDelete' ).unbind( "click" );
		$listContainer.empty();
		
		// 타이틀 추가
		var _tr;
		_tr = "<thead>";
		_tr += "<tr>";
		_tr += 		"<td>NO</td>";
		_tr +=  	"<td>댓글</td>";
		_tr +=  	"<td>작성자</td>";
		_tr +=  	"<td>등록일</td>";
		_tr +=  	"<td>DELETE</td>";
		_tr += "</tr>";
		_tr += "</thead>";
		_tr += "<tbody>";
		// 리스트 추가
		var _no = (_commentPage.current-1)*_commentPage.numPerPage+1;
		for( var index in data.comment )
		{
			var _item = data.comment[ index ];
			_tr += "<tr>";
			_tr += 		"<td>"+(_no++)+"</td>";
			_tr += 		"<td>"+_item[ 'comment' ]+"</td>";
			_tr += 		"<td>"+_item[ 'nickname' ]+"</td>";
			_tr += 		"<td>"+_item[ 'register' ]+"</td>";
			_tr += 		"<td>"+(_item[ 'owner_id' ]==login_member_id()?"<input type='button' class='btnDelete' value='DELETE' data='"+_item[ 'seq' ]+"'/>":'')+"</td>";			
			_tr += "</tr>";
		}
		_tr += "</tbody>";
		$listContainer.append( _tr );
		
		// 수정 버튼 이벤트 등록
		$listContainer.find( '.btnDelete' ).bind( "click", null, function(e) {
			var $comment_seq = $(this).attr( 'data' );
			deleteFreeBoardComment( $comment_seq );
		});
		
		// 페이징
		_commentPage.setTotalCount( data.count );
		_commentPage.updateLabelField();
	}
	
	// 조회 실패
	function freeBoardCommentsRefreshFail( data )
	{
		setResultFailForJSON( '[ 댓글 조회] 실패', data );
	};
	
	// 입력
	$( '#insertFreeBoardCommentForm' ).submit(function(e) {
        e.preventDefault();
		
		
		var _formData = new FormData( document.getElementById( 'insertFreeBoardCommentForm' ) );
		_formData.append( '__key__', 'insertFreeBoardComment' );
		_formData.append( '__returnType__', 'json' );
		_formData.append( 'login_member_id', login_member_id() );
		_formData.append( 'login_member_session', login_member_session() );
		
		$.ajax(
		{
			url: getGatePath(),
			data: _formData,
			dataType:'json',
			processData: false,
			contentType: false,
			type: "POST",
			success: function( data )
			{
				if( data.result == 'SUCCESS' )
				{
					setResult( '[코멘트 추가] 성공' );
					// 리스트 갱신
					selectAllFreeBoardComments( _commentPage.current, _commentPage.numPerPage, freeBoardCommentsRefreshSuccess, freeBoardCommentsRefreshFail );
				}else{
					setResultFailForJSON( '[코멘트 추가] 실패', data );
				}
			}
		});
    });
	
	// 댓글 삭제
	function deleteFreeBoardComment( $comment_seq )
	{
		$.post(
			getGatePath()
			,
			{
				__key__: 'deleteFreeBoardComment',
				__returnType__: 'json',
				login_member_id: login_member_id(),
				login_member_session: login_member_session(),
				seq: $comment_seq
			}
			,
			function( data )
			{
				if( data.result == 'SUCCESS' )
				{
					setResult( '[코멘트 삭제] 성공' );
					// 리스트 갱신
					selectAllFreeBoardComments( _commentPage.current, _commentPage.numPerPage, freeBoardCommentsRefreshSuccess, freeBoardCommentsRefreshFail );
				}else{
					setResultFailForJSON( '[코멘트 삭제] 실패', data );
				}
			}
			,
			'json' );
	}
	
	// 상세 팝업 활성
	function showUpdateFreeBoardPopup( $board_seq )
	{
		$.post( getGatePath(),
			{
				__key__: 'selectFreeBoardDetail',
				__returnType__: 'json',
				login_member_id: login_member_id(),
				login_member_session: login_member_session(),
				seq: $board_seq
			}, 
			function( data )
			{
				if( data.result == "SUCCESS" )
				{
					setResult( '[ 상세 정보 조회] 성공' );
					
					// [[ 팝업 셋팅 ]]
					var $popup = $( "#updateFreeBoard" );
					$popup.show();
					
					$popup.find( '[name="seq"]' ).val( data[ 'seq' ] );
					$popup.find( '[name="title"]' ).val( data[ 'title' ] );
					$popup.find( '[name="ownerNickname"]' ).val( data[ 'owner_nickname' ] );
					$popup.find( '[name="ownerId"]' ).val( data[ 'owner_id' ] );
					$popup.find( '[name="registDate"]' ).val( data[ 'regist_date' ] );
					$popup.find( '[name="desc"]' ).val( data[ 'desc' ] );
					
					// 썸네일 정보
					// 썸네일 정보
					var _thumbnails = null;
					if( data[ 'thumbnails' ] )
					{
						_thumbnails = data[ 'thumbnails' ][ 'thumb' ];
					}
					setPicture( $popup
								, null
								, _thumbnails );
					
				}else{
					setResultFailForJSON( '[ 상세 정보 조회 ] 실패', data );
				}
			},
			'json' );
	}
	
	
	
	
	// 상세 팝업 수정
	$( '#updateFreeBoardForm' ).submit(function(e) {
		e.preventDefault();
		
		var _formData = new FormData( document.getElementById( 'updateFreeBoardForm' ) );
		_formData.append( '__key__', 'updateFreeBoard' );
		_formData.append( '__returnType__', 'json' );
		_formData.append( 'login_member_id', login_member_id() );
		_formData.append( 'login_member_session', login_member_session() );
		
		$.ajax(
		{
			url: getGatePath(),
			data: _formData,
			dataType:'json',
			processData: false,
			contentType: false,
			type: "POST",
			success: function( data )
			{
				if( data.result == 'SUCCESS' )
				{
					setResult( '[ 정보 수정] 성공' );
					
					var $popup = $( "#updateFreeBoard" );
					$popup.hide();
					
					// 목록 갱신
					selectAllFreeBoard( _listPage.current, _listPage.numPerPage, boardRefreshSuccess, boardRefreshFail );
				}else{
					setResultFailForJSON( '[ 정보 수정] 실패', data );
				}
			}
		});
    });
	
	// 비활성 처리
	function disactiveFreeBoard( $board_seq )
	{
		if( confirm( "삭제하시겠습니까?" ) )
		{
			$.post( getGatePath(),
				{
					__key__: 'deleteFreeBoard',
					__returnType__: 'json',
					login_member_id: login_member_id(),
					login_member_session: login_member_session(),
					seq: $board_seq
				}, 
				function( data )
				{
					if( data.result == "SUCCESS" )
					{
						setResult( '[ 삭제 ] 성공' );
						
						// 목록 갱신
						selectAllFreeBoard( _listPage.current, _listPage.numPerPage, boardRefreshSuccess, boardRefreshFail );
					}else{
						setResultFailForJSON( '[ 삭제 ] 실패', data );
					}
				},
				'json' );
		}
	}
}